<?php
/**
 * 获取配置
 * @param $key
 * @return bool|array
 * @throws \Base\BaseException
 */
function config($key)
{
    $di = \EasySwoole\Component\Di::getInstance();
    try {
        $config = $di->get("config");
        $config['env'] = $di->get("env");
        foreach (explode('.', $key) as $k) {
            $config = $config[$k] ?? false;
            if (!$config) {
                return [];
            }
        }
        return $config;
    } catch (Throwable $e) {
        throw new \Base\BaseException("载入config失败");
    }
}
